#include <iostream>
#include <unistd.h>
#include <pthread.h>

__thread int count = 1;

void* routine1(void* args)
{
    (void)args;
    while (true)
    {
        printf("I am thread-1, the count is %d, and the count address is %p, and count++.\n", count, &count);
        count++;
        sleep(1);
    }

    return nullptr;
}

void* routine2(void* args)
{
    (void)args;
    while(true)
    {
        printf("I am thread-2, the count is %d, and the count address is %p.\n", count, &count);
        sleep(1);
    }

    return nullptr;
}

int main()
{
    pthread_t tid1, tid2;
    pthread_create(&tid1, nullptr, routine1, nullptr);
    pthread_create(&tid2, nullptr, routine2, nullptr);

    pthread_join(tid1, nullptr);
    pthread_join(tid2, nullptr);
    return 0;
}